﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GaiNo.Core.Helpers;
namespace GaiNo.Core.Extensions
{
    public static class UriExtensions
    {
        public static string GetSLD(this Uri uri)
        {
            return uri.Host.Split('.').First();
        }
        public static string GetIP(this Uri uri)
        {
            try
            {
                System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(uri.Host);
                return host.AddressList.GetValue(0).ToString();
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }
        public static bool CurrentDomain(this Uri uri)
        {
            return uri.Host.Contains(AuthenticationHelper.Domain);
        }
    }
}
